package com.example.dazhuang.web;

import com.alibaba.fastjson.JSONObject;
import com.example.dazhuang.util.JsonUtils;
import com.example.dazhuang.vo.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/")
public class IndexController {

    @PostMapping("/private/workOrder2/createWorkorder")
    @ResponseBody
    public String createWorkOrder(@RequestBody String params){
        WorkOrderInfoReq workOrderInfoReq = JsonUtils.json2Obj(params, WorkOrderInfoReq.class);
        WorkOrderInfoRes workOrderInfoRes = new WorkOrderInfoRes(WorkOrderReturnCode.ORDER_ACCEPTED,"","",workOrderInfoReq.getExternalOrderId());
        String response = JsonUtils.obj2Json(workOrderInfoRes);
        return response;
    }

    @GetMapping("/order/get")
    @ResponseBody
    public String getWorkOrder(){
        OrderRes orderRes = new OrderRes();
        Order order = new Order();
        order.setStatus(OrderStatus.SUCCESS);
        orderRes.setOrder(order);
        orderRes.setResultCode(WorkOrderReturnCode.QUERY_REQUEST_ACCEPTED);
        String response = JsonUtils.obj2Json(orderRes);
        return response;
    }

    @RequestMapping("/private/account/recharge")
    @ResponseBody
    public String recharge(){
        TicketVO ticketVO = new TicketVO();
        ticketVO.setResultCode("ACCEPTED");
        String response = JsonUtils.obj2Json(ticketVO);
        return response;
    }

}
